<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html" %>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<%@include file="/commons/page/codegen.jsp" %>
		<script type="text/javascript" src="${ctx}/js/gpoint/rdp/SearchController/searchController.js"></script>
	</head>
	    <body>
		<!-- 顶部按钮 -->
		<div class="wrapper wrapper-content  animated fadeInRight col-sm-12">
   			<div style="height:60px;" >

			</div>
		   
			<div class="" >
			  
			    
				<form  class="fr-form"  id="searchControllerForm">
				     <input id="productid" type="hidden"  name="productid" value="${searchController.productid}" validate="{required:false}"/>
				     <input id="yourip" type="hidden"  name="yourip" value="${searchController.yourip}" validate="{required:false}"/><!-- 服务IP -->
				     <input id="notes" type="hidden"  name="notes" value="${searchController.notes}" validate="{required:false}"/>
					 <div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">产品序列号</label>
						  	<div class="fr-form-block" data-type="fixed">
						         <input id="productsn" readonly= "readonly" type="text" class="fr-form-control" name="productsn" value="${searchController.productsn}" validate="{required:false}"/>				
						 	</div>
					  	</div>
					 </div>
					 <div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">MAC地址</label>
						  	<div class="fr-form-block" data-type="fixed">
						          <input id="mac" readonly= "readonly" type="text" class="fr-form-control" name="mac" value="${searchController.mac}" validate="{required:false}"/>						  					
						 	</div>
					  	</div>
					</div>
					<div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">子网掩码</label>
						  	<div class="fr-form-block" data-type="fixed">
						          <input id="submask" type="text" class="fr-form-control" name="submask" value="${searchController.submask}" validate="{required:false}"/>
						  					
						 	</div>
					  	</div>
					</div>
					<div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">网关</label>
						  	<div class="fr-form-block" data-type="fixed">
						           <input id="gateway" type="text" class="fr-form-control" name="gateway" value="${searchController.gateway}" validate="{required:false}"/>
						  					
						 	</div>
					  	</div>
					</div>
					<div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">IP地址</label>
						  	<div class="fr-form-block" data-type="fixed">
						        <input id="pcip" type="text" class="fr-form-control" name="pcip" value="${searchController.pcip}" validate="{required:false}"/>			
						 	</div>
					  	</div>
					</div>
					<div class="fr_response_field col-sm-10" >
					 	<div class="fr-form-group"> 
						 	<label class="fr-control-label">PORT</label>
						  	<div class="fr-form-block" data-type="fixed">
						           <input id="port" type="text" class="fr-form-control" name="port" value="${searchController.port}" validate="{required:false}"/>
						  					
						 	</div>
					  	</div>
					</div>
				 	
		        </form>
			</div>
		</div>
		
		
		<script type="text/javascript">
		   var editUrl = "${editUrl}";				   
		   function editController(index,closefunc){
			   //参数获取
			   var productid = $("#productid").val();
			   var yourip = $("#yourip").val();
			   var notes = $("#notes").val();
			   var mac = $("#mac").val(); 
			   var productsn = $("#productsn").val();
			   var submask = $("#submask").val();
			   var gateway = $("#gateway").val();
			   var pcip = $("#pcip").val();
			   var port = $("#port").val();
			   //本地修改传参
			   var datas=[];
			   var map ={};
			   map.productid=productid;
			   map.productsn=productsn;
			   map.pcip	=pcip;	
			   map.submask=submask;
			   map.gateway=gateway;
			   map.port=port;
			   map.mac=mac;
			   map.yourip=yourip;						
			   map.notes=notes;
			   datas.push(map);
			   var params = {};
			   params.datas = datas;
			   
			   var urlNet =editUrl+"?sn="+productsn+"&port="+ port+"&ipaddress="+pcip+"&ywAddress="+submask+"&getwayAddress="+gateway;
			   
			   $.ajax({
					url : urlNet,
					type : "GET",
					//contentType : "application/json",
					//data:JSON.stringify(map),
					dataType : "json",
					async : false,
					success : function(data) {
						if(200 != data.code){
							DialogUtil.error(data.text);
							return;
						}
						var f = editLocal(params);
						if(f){
							DialogUtil.msg(data.text);
						}
						
						closefunc();//关闭窗口
					},
					error:function(xhr,textStatus){
						DialogUtil.error("保存失败");
					}
			   
				});	   
			   

			  
		   }
		   
		   function editLocal(params){
 
			   var url ="${ctx}/rdp/SearchController/searchController/update.htm";
			   var f = false;
			   $.ajax({
					url : url,
					type : "POST",
					contentType : "application/json",
					data:JSON.stringify(params),
					dataType : "json",
					async : false,
					success : function(data) {
						//DialogUtil.msg(data.message);
						if(data.result=="0"){
							f = true
						}else{
							DialogUtil.msg(data.message);
						}
						
					},
					error:function(xhr,textStatus){
						DialogUtil.error("本地保存失败");
					}
			   
				});	
			   
			    return f;
			   
		   }
		   
		
		</script>
	</body>
</html>